import request from '@/utils/request'

// api地址
const api = {
  list: 'goodCart/',
  total: 'goodCart/goodsItemSum/',
  add: 'goodCart/',
  update: 'goodCart/',
}

// 购物车列表
export const list = () => {
  return request.get(api.list, {current:1,size:10000}, { load: false })
}

// 购物车商品总数量
export const total = () => {
  return request.get(api.total, {}, { load: false })
}

// 加入购物车
export const add = (goodsId, goodsItemId, count) => {
  return request.post(api.add, { goodsId, goodsItemId, count })
}

// 更新购物车商品数量
export const update = (id, goodsItemId, count) => {
  return request.put(api.update+id, { id, goodsItemId, count }, { isPrompt: false })
}

// 删除购物车中指定记录
export const clear = (ids = []) => {
  return request.delete(api.list, { ids })
}
